package com.combetter.changxing.db.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import com.combetter.changxing.db.Facility;

import java.util.List;

/**
 * 已配对设备本地数据库
 */
@Dao
public interface FacilityDao {
    /**
     * 查询所有设备信息
     *
     * @return
     */
    @Query("SELECT * FROM facility_table")
    List<Facility> getFacilityInfoList();

    @Query("SELECT * FROM facility_table WHERE _uid = :uid")
    List<Facility> findByUid(String uid);

    @Query("SELECT * FROM facility_table WHERE _facilityAddress = :mac")
    Facility findByMac(String mac);


    /**
     * 添加设备信息
     *
     * @param facilitys
     * @return
     */
    @Insert
    void insertAllOrSingle(Facility... facilitys);

    /**
     * 修改设备信息
     *
     * @param facilities
     */
    @Update
    void update(Facility facilities);

    /**
     * 删除设备信息
     */
    @Delete
    void deleteFacility(Facility facility);

    //根据名字删除
    @Query("DELETE  FROM facility_table where _facilityAddress=:mac")
    void deleteFacilityByMac(String mac);
}
